package com.douyang.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.douyang.base.model.Result;
import com.douyang.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2025-03-03
 */
@RestController
@RequestMapping("/user/userRole")
public class UserRoleController {
    @Autowired
    private UserRoleService userRoleService;

    @PostMapping("/getUserRole")
    public Result<List<String>> getUserRole(@RequestBody Long userId) {
        return Result.success(userRoleService.getUserRole(userId));
    }

    @GetMapping("/checkRole")
    public Result<Boolean> checkRole(String role) {
        return Result.success(StpUtil.hasRole(role));
    }

    @PostMapping("/signAgreePresenter")
    public Result<String> signAgreePresenter() {
        userRoleService.signAgreePresenter();

        return Result.success("ok");
    }
}
